

<!DOCTYPE html>
<html>
<head>
    <title>收货人地址管理 - 花予网</title>
    <link type="text/css" rel="stylesheet" href="//img02.hua.com/pc/assets/css/common.css">
    <link type="text/css" rel="stylesheet" href="//img02.hua.com/pc/assets/css/public.css">
    <!--[if lt IE 9]>
    <script src="//img02.hua.com/pc/assets/js/html5shiv.min.js"></script>
    <![endif]-->
    <style>
        .had_area {
            position: absolute;
            top: 6px;
            left: 24px;
            font-size: 13px;
        }
    </style>
</head>
<body>
<div id="consigneeModal">
    <form class="form-horizontal form-group-sm" id="addressOper" action="/shop/saveUserAddress" method="post">
        <div class="form-group">
            <label  class="col-xs-2 control-label">收货人姓名:</label>
            <div class="col-xs-2">
                <input type="text" class="form-control" id="customerName" name="customerName" value="" maxlength="15" autocomplete="off" autofocus>
            </div>
        </div>
        <div class="form-group">
            <label  class="col-xs-2 control-label">收货人手机:</label>
            <div class="col-xs-3">
                <input type="text" class="form-control" id="customerPhone" name="customerPhone" value="" autocomplete="off" maxlength="25">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-2 control-label">省 市 区:</label>
            <div class="col-xs-9" id="city_1">
                <div class="col-xs-4">
                    <select  onchange="initfindProvinceCode(this.value,-2)"  id="shengId" name="shengId"></select>
                </div>
                <div class="col-xs-4">
                    <select  onchange="initfindCityCode(this.value,-3)"  id="shiId" name="shiId"></select>
                </div>
                <div class="col-xs-4">
                    <select  id="quId" name="quId"></select>
                </div>
                <span class="help-block col-xs-12">注：地区请选择</span>
            </div>
        </div>
        <div class="form-group">
            <label  class="col-xs-2 control-label">详细地址:</label>
            <div class="col-xs-10" style="position:relative;">
                <input type="text" class="form-control" placeholder="请输入详细地址" id="customerAddress" name="customerAddress" value="" maxlength="120" autocomplete="off">
                <span class="had_area"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-offset-2 col-xs-10">
                <button type="button" class="btn btn-default btn-tinge" onClick="return confirmForm();" id="dosubmit">保存收货人信息</button>
                <button type="button" class="btn btn-default btn-tinge" disabled="disabled" style="display:none" id="submiting">保存中...</button>&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-default btn-tinge" onClick="DoClear();">清除</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="//img02.hua.com/pc/js/common.js"></script>
<script type="text/javascript" src="//img02.hua.com/pc/js/jquery.citysel.js"></script>
<script type="text/javascript">

    $(function(){
        initfindProvinceCode(0,-1);
    });

    //地区 省
    function initfindProvinceCode(pid,falg){

        var str='<option value="-1">请选择</option>'
        $.ajax({
            url:'../web/getProviceBind',
            type:'post',
            dataType:'json',
            data:{pid:pid},
            success:function (data) {

                for (var i = 0; i < data.length; i++) {
                    str+='<option value="'+data[i].id+'">'+data[i].cname+'</option>'
                }
                if(falg==-1){
                    $("#shengId").html(str);
                }
                if(falg==-2){
                    $("#shiId").html(str);
                }
            }

        })
    }
    //区
    function initfindCityCode(pid,falg){
        var str='<option value="-1">请选择</option>'

        $.post('../web/getProviceBind',{pid:pid},function(data){
            for (var i = 0; i < data.length; i++) {
                str+='<option value="'+data[i].id+'">'+data[i].cname+'</option>'
            }
            $("#quId").html(str);
        })
    }


    function confirmForm() {
        if (myTrim($("#customerName").val()).length <= 0) {
            alert("请填写收货人");
            $("#customerName").focus();
            return false;
        }
        if (myTrim($("#customerPhone").val()).length <= 0 && myTrim($("#customerPhone").val()).length <= 0) {
            alert("请填写收货人手机号或电话！");
            $("#customerPhone").focus();
            return false;
        }
        if ($("#customerPhone").val().length > 0 && $("#customerPhone").val().length < 11) {
            alert("请填写正确的11位手机号码！");
            $("#customerPhone").focus();
            return false;
        }
        if ($("#customerPhone").val().trim().length > 0 && !(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test($("#customerPhone").val().trim())))
        {
            alert("请填写正确的11位手机号码！");
            $("#to_mobile").focus();
            return false;
        }
        var toState1 = $("#shengId").val();
        if (toState1 == null || toState1 == '' || toState1 == "请选择省份") {
            alert("请选择收货人省份！");
            return false;
        }
        var toCity1 = $("#shiId").val();
        if (toCity1 == null || toCity1 == '' || toCity1 == "请选择城市") {
            alert("请选择收货人城市！");
            return false;
        }
        var toArea1 = $("#quId").val();
        if (toArea1 == null || toArea1 == '' || toArea1 == "请选择区县") {
            alert("请选择收货人区县！");
            return false;
        }
        if (myTrim($("#customerAddress").val()).length <= 2) {
            alert("请填写收货人详细地址！");
            $("#customerAddress").focus();
            return false;
        }

        debugger
        $("#dosubmit").hide();
        $("#submiting").show();
        $("#addressOper").submit();

        $("#attAddrPage").attr('src', '/page/toOrderSettlement');

    }



    function DoClear() {
        $("#customerName").val("");
        $("#customerPhone").val("");

        $("#customerAddress").val("");
        $("#city_1").citySelect({
            prov: "请选择省份",
            city: "请选择城市",
            dist: "请选择区县",
            distval: "",
            nodata: "none"
        });
    }
    function myTrim(x) {
        return x.replace(/^\s+|\s+$/gm, '');
    }

</script>
</body>
</html>